package com.mb.app.appused.views;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

/**
 * @author wo2app
 * @date 创建时间：2015年2月18日 上午11:14:20
 * @version 1.0
 * @parameter
 * @since
 * @return
 */

public class CustomDialog extends Dialog {

	Context context;
	View view;

	public CustomDialog(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		this.context = context;

	}

	public CustomDialog(Context context, int defStyle) {
		super(context, defStyle);
		this.context = context;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

	}

	public void setView(View view) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(view);
		this.view = view;
	}

	public void setView(int layout) {
		//requestWindowFeature(Window.FEATURE_NO_TITLE);
		// setContentView(layout);
		LayoutInflater inflater = LayoutInflater.from(context);
		setView(inflater.inflate(layout, null));
	}

	public View getView() {
		return this.view;
	}

	public Button getButton(int id) {
		return (Button) view.findViewById(id);
	}

	public TextView getTextView(int id) {
		return (TextView) view.findViewById(id);
	}

	public View getObject(int id) {
		return view.findViewById(id);
	}

	public void setViewClick(View child, final ViewClick click) {
		child.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Log.e("info", "abc");
				click.OnClick();
			}
		});
	}

	public interface ViewClick {
		void OnClick();
	}

}
